using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.XR.Interaction.Toolkit.Interactables;

public class Weapon : MonoBehaviour
{
    private XRGrabInteractable mInteractable;
    private ParticleSystem mEffect;
    void Start()
    {
        mEffect = transform.Find("Confetti").GetComponent<ParticleSystem>();
        mInteractable = GetComponent<XRGrabInteractable>();
        mInteractable.hoverEntered.AddListener(OnHoverEntered);
        mInteractable.selectEntered.AddListener(OnSelectEntered);
        mInteractable.focusEntered.AddListener(OnFocusEntered);
        mInteractable.activated.AddListener(OnActivated);
    }

    private void OnActivated(ActivateEventArgs arg0)
    {
        Debug.Log("Activated:"+arg0.interactorObject.transform.name);
        mEffect.Play();
    }

    private void OnFocusEntered(FocusEnterEventArgs arg0)
    {
        Debug.Log("Focus Enter:"+arg0.interactorObject.transform.name);
    }

    private void OnSelectEntered(SelectEnterEventArgs arg0)
    {
        Debug.Log("Select Enter:"+arg0.interactorObject.transform.name);
    }

    private void OnHoverEntered(HoverEnterEventArgs arg0)
    {
        Debug.Log("Hover Enter:"+arg0.interactorObject.transform.name);
    }
}
